<template>
  <div class="good-single" @click="goDtail">
    <img v-if="good.s_goods_photos" :src="good.s_goods_photos[0].path" alt="" />
    <p class="title">{{ good.name }}</p>
    <p class="discribe">{{ good.desc }}</p>
    <p class="price">￥{{ good.price }}</p>
  </div>
</template>

<script>
export default {
  name: "GoodSingle",
  data() {
    return {
      good: {},
    };
  },
  props: ["item"],
  methods: {
    goDtail() {
      this.$router.push({
        name: "detail",
        params: {
          id: this.item.id,
        },
      });
    },
  },
  mounted() {
    this.good = this.item;
  },
};
</script>

<style lang="scss" scoped>
.good-single {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 220px;
  height: 230px;
  padding: 20px 0;
  background-color: white;
  transition: all 0.5s;
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px lightgray;
  }
  &:nth-of-type(5n) {
    margin-right: 0;
  }
  img {
    width: 160px;
    height: 160px;
  }
  p {
    height: 20px;
    padding: 0 10px;
    line-height: 20px;
  }
  .title {
    margin-top: 5px;
    text-align: center;
    font-size: 16px;
    color: black;
    overflow: hidden;
  }
  .discribe {
    font-size: 12px;
    color: #b0b0b0;
    overflow: hidden;
  }
  .price {
    font-size: 16px;
    color: #ff6700;
  }
}
</style>
